In [ ]:
%pip install jupyter plotly numpy pandas statsmodels
%pip install --upgrade nbformat
Requirement already satisfied: jupyter in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (1.0.0) Requirement already satisfied: plotly in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (5.18.0) Requirement already satisfied: numpy in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (1.26.3) Requirement already satisfied: pandas in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (2.1.4) Requirement already satisfied: statsmodels in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (0.14.1) Requirement already satisfied: ipywidgets in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter) (8.1.1) Requirement already satisfied: qtconsole in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter) (5.5.1) Requirement already satisfied: jupyter-console in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter) (6.6.3) Requirement already satisfied: ipykernel in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter) (6.28.0) Requirement already satisfied: notebook in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter) (7.0.6) Requirement already satisfied: nbconvert in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter) (7.14.1) Requirement already satisfied: packaging in c:\users\looper\appdata\roaming\python\python310\site-packages (from plotly) (23.2) Requirement already satisfied: tenacity>=6.2.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from plotly) (8.2.3) Requirement already satisfied: pytz>=2020.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from pandas) (2023.3.post1) Requirement already satisfied: tzdata>=2022.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from pandas) (2023.4) Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\looper\appdata\roaming\python\python310\site-packages (from pandas) (2.8.2) Requirement already satisfied: scipy!=1.9.2,>=1.4 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from statsmodels) (1.11.4) Requirement already satisfied: patsy>=0.5.4 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from statsmodels) (0.5.6) Requirement already satisfied: six in c:\users\looper\appdata\roaming\python\python310\site-packages (from patsy>=0.5.4->statsmodels) (1.16.0) Requirement already satisfied: jupyter-client>=6.1.12 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (8.6.0) Requirement already satisfied: comm>=0.1.1 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (0.2.1) Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (5.7.1) Requirement already satisfied: psutil in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (5.9.7) Requirement already satisfied: ipython>=7.23.1 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (8.20.0) Requirement already satisfied: tornado>=6.1 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (6.4) Requirement already satisfied: matplotlib-inline>=0.1 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (0.1.6) Requirement already satisfied: pyzmq>=24 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (25.1.2) Requirement already satisfied: traitlets>=5.4.0 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (5.14.1) Requirement already satisfied: nest-asyncio in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (1.5.8) Requirement already satisfied: debugpy>=1.6.5 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipykernel->jupyter) (1.8.0) Requirement already satisfied: widgetsnbextension~=4.0.9 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from ipywidgets->jupyter) (4.0.9) Requirement already satisfied: jupyterlab-widgets~=3.0.9 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from ipywidgets->jupyter) (3.0.9) Requirement already satisfied: prompt-toolkit>=3.0.30 in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter-console->jupyter) (3.0.43) Requirement already satisfied: pygments in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter-console->jupyter) (2.17.2) Requirement already satisfied: jupyterlab-pygments in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (0.3.0) Requirement already satisfied: beautifulsoup4 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (4.12.2) Requirement already satisfied: mistune<4,>=2.0.3 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (3.0.2) Requirement already satisfied: nbclient>=0.5.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (0.9.0) Requirement already satisfied: nbformat>=5.7 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (5.9.2) Requirement already satisfied: bleach!=5.0.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (6.1.0) Requirement already satisfied: tinycss2 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (1.2.1) Requirement already satisfied: defusedxml in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (0.7.1) Requirement already satisfied: jinja2>=3.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (3.1.3) Requirement already satisfied: markupsafe>=2.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (2.1.3) Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbconvert->jupyter) (1.5.0) Requirement already satisfied: jupyter-server<3,>=2.4.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from notebook->jupyter) (2.12.4) Requirement already satisfied: jupyterlab-server<3,>=2.22.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from notebook->jupyter) (2.25.2) Requirement already satisfied: notebook-shim<0.3,>=0.2 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from notebook->jupyter) (0.2.3) Requirement already satisfied: jupyterlab<5,>=4.0.2 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from notebook->jupyter) (4.0.10) Requirement already satisfied: qtpy>=2.4.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from qtconsole->jupyter) (2.4.1) Requirement already satisfied: webencodings in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from bleach!=5.0.0->nbconvert->jupyter) (0.5.1) Requirement already satisfied: decorator in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipython>=7.23.1->ipykernel->jupyter) (5.1.1) Requirement already satisfied: jedi>=0.16 in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipython>=7.23.1->ipykernel->jupyter) (0.19.1) Requirement already satisfied: stack-data in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipython>=7.23.1->ipykernel->jupyter) (0.6.3) Requirement already satisfied: exceptiongroup in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipython>=7.23.1->ipykernel->jupyter) (1.2.0) Requirement already satisfied: colorama in c:\users\looper\appdata\roaming\python\python310\site-packages (from ipython>=7.23.1->ipykernel->jupyter) (0.4.6) Requirement already satisfied: platformdirs>=2.5 in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel->jupyter) (4.1.0) Requirement already satisfied: pywin32>=300 in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter-core!=5.0.*,>=4.12->ipykernel->jupyter) (306) Requirement already satisfied: websocket-client in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (1.7.0) Requirement already satisfied: pywinpty in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (2.0.12) Requirement already satisfied: overrides in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (7.4.0) Requirement already satisfied: send2trash>=1.8.2 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (1.8.2) Requirement already satisfied: terminado>=0.8.3 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (0.18.0) Requirement already satisfied: argon2-cffi in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (23.1.0) Requirement already satisfied: prometheus-client in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (0.19.0) Requirement already satisfied: jupyter-server-terminals in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (0.5.1) Requirement already satisfied: jupyter-events>=0.9.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (0.9.0) Requirement already satisfied: anyio>=3.1.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-server<3,>=2.4.0->notebook->jupyter) (4.2.0) Requirement already satisfied: async-lru>=1.0.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab<5,>=4.0.2->notebook->jupyter) (2.0.4) Requirement already satisfied: jupyter-lsp>=2.0.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab<5,>=4.0.2->notebook->jupyter) (2.2.1) Requirement already satisfied: tomli in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab<5,>=4.0.2->notebook->jupyter) (2.0.1) Requirement already satisfied: babel>=2.10 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2.14.0) Requirement already satisfied: jsonschema>=4.18.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab-server<3,>=2.22.1->notebook->jupyter) (4.20.0) Requirement already satisfied: json5>=0.9.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab-server<3,>=2.22.1->notebook->jupyter) (0.9.14) Requirement already satisfied: requests>=2.31 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2.31.0) Requirement already satisfied: fastjsonschema in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbformat>=5.7->nbconvert->jupyter) (2.19.1) Requirement already satisfied: wcwidth in c:\users\looper\appdata\roaming\python\python310\site-packages (from prompt-toolkit>=3.0.30->jupyter-console->jupyter) (0.2.13) Requirement already satisfied: soupsieve>1.2 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from beautifulsoup4->nbconvert->jupyter) (2.5) Requirement already satisfied: idna>=2.8 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (3.6) Requirement already satisfied: typing-extensions>=4.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (4.9.0) Requirement already satisfied: sniffio>=1.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from anyio>=3.1.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (1.3.0) Requirement already satisfied: parso<0.9.0,>=0.8.3 in c:\users\looper\appdata\roaming\python\python310\site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel->jupyter) (0.8.3) Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2023.12.1) Requirement already satisfied: referencing>=0.28.4 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (0.32.1) Requirement already satisfied: attrs>=22.2.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (23.2.0) Requirement already satisfied: rpds-py>=0.7.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (0.16.2) Requirement already satisfied: python-json-logger>=2.0.4 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (2.0.7) Requirement already satisfied: rfc3339-validator in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (0.1.4) Requirement already satisfied: rfc3986-validator>=0.1.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (0.1.1) Requirement already satisfied: pyyaml>=5.3 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jupyter-events>=0.9.0->jupyter-server<3,>=2.4.0->notebook->jupyter) (6.0.1) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.31->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2.1.0) Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.31->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (3.3.2) Requirement already satisfied: certifi>=2017.4.17 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from requests>=2.31->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2023.11.17) Requirement already satisfied: argon2-cffi-bindings in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from argon2-cffi->jupyter-server<3,>=2.4.0->notebook->jupyter) (21.2.0) Requirement already satisfied: executing>=1.2.0 in c:\users\looper\appdata\roaming\python\python310\site-packages (from stack-data->ipython>=7.23.1->ipykernel->jupyter) (2.0.1) Requirement already satisfied: asttokens>=2.1.0 in c:\users\looper\appdata\roaming\python\python310\site-packages (from stack-data->ipython>=7.23.1->ipykernel->jupyter) (2.4.1) Requirement already satisfied: pure-eval in c:\users\looper\appdata\roaming\python\python310\site-packages (from stack-data->ipython>=7.23.1->ipykernel->jupyter) (0.2.2) Requirement already satisfied: jsonpointer>1.13 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2.4) Requirement already satisfied: fqdn in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (1.5.1) Requirement already satisfied: webcolors>=1.11 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (1.13) Requirement already satisfied: isoduration in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (20.11.0) Requirement already satisfied: uri-template in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (1.3.0) Requirement already satisfied: cffi>=1.0.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from argon2-cffi-bindings->argon2-cffi->jupyter-server<3,>=2.4.0->notebook->jupyter) (1.16.0) Requirement already satisfied: pycparser in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->jupyter-server<3,>=2.4.0->notebook->jupyter) (2.21) Requirement already satisfied: arrow>=0.15.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from isoduration->jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (1.3.0) Requirement already satisfied: types-python-dateutil>=2.8.10 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from arrow>=0.15.0->isoduration->jsonschema>=4.18.0->jupyterlab-server<3,>=2.22.1->notebook->jupyter) (2.8.19.20240106) Note: you may need to restart the kernel to use updated packages.
[notice] A new release of pip available: 22.3.1 -> 23.3.2 [notice] To update, run: python.exe -m pip install --upgrade pip
Requirement already satisfied: nbformat in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (5.9.2) Requirement already satisfied: jupyter-core in c:\users\looper\appdata\roaming\python\python310\site-packages (from nbformat) (5.7.1) Requirement already satisfied: fastjsonschema in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbformat) (2.19.1) Requirement already satisfied: traitlets>=5.1 in c:\users\looper\appdata\roaming\python\python310\site-packages (from nbformat) (5.14.1) Requirement already satisfied: jsonschema>=2.6 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from nbformat) (4.20.0) Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=2.6->nbformat) (2023.12.1) Requirement already satisfied: attrs>=22.2.0 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=2.6->nbformat) (23.2.0) Requirement already satisfied: rpds-py>=0.7.1 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=2.6->nbformat) (0.16.2) Requirement already satisfied: referencing>=0.28.4 in c:\users\looper\appdata\local\programs\python\python310\lib\site-packages (from jsonschema>=2.6->nbformat) (0.32.1) Requirement already satisfied: platformdirs>=2.5 in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter-core->nbformat) (4.1.0) Requirement already satisfied: pywin32>=300 in c:\users\looper\appdata\roaming\python\python310\site-packages (from jupyter-core->nbformat) (306) Note: you may need to restart the kernel to use updated packages.
[notice] A new release of pip available: 22.3.1 -> 23.3.2 [notice] To update, run: python.exe -m pip install --upgrade pip
In [ ]:
import pandas as pd
import numpy as np
import plotly.express as px
data= pd.read_csv("spotify-2023.csv")
data['streams'] = pd.to_numeric(data['streams'], errors='coerce')
In [ ]:
most_streamed = data.loc[data.groupby('released_year')['streams'].idxmax()]
clean_data = most_streamed[['track_name', 'artist(s)_name', 'released_year', 'streams']]
fig = px.bar(clean_data, x='released_year', y='streams')
fig.show(renderer='notebook')
In [ ]:
top_songs = data.groupby('released_year').apply(lambda group : group.nlargest(3, 'streams')).reset_index(drop=True)
top_songs = top_songs[['track_name', 'artist(s)_name', 'released_year', 'streams']]
top_songs = top_songs.query("""released_year >= 2010""" )
fig = px.bar(top_songs, x='released_year', y='streams' , hover_data=['track_name' , 'artist(s)_name'] , color_continuous_scale="EARTH" , color="streams" , title='Top 3 songs')
fig.show(renderer='notebook')
In [ ]:
song_keys = data[["released_year" , "key" , "streams"]]
group = song_keys.groupby('key')['streams'].sum().reset_index()
def to_millions(x):
return x / 1e6